Function @"switch" [src]

Prototype

pub fn @"switch"( self: *WipFunction, val: Value, default: Block.Index, cases_len: u32, weights: Instruction.BrCond.Weights, ) Allocator.Error!WipSwitch

Parameters

self: *WipFunctionval: Valuedefault: Block.Indexcases_len: u32weights: Instruction.BrCond.Weights

Source

pub fn @"switch"( self: *WipFunction, val: Value, default: Block.Index, cases_len: u32, weights: Instruction.BrCond.Weights, ) Allocator.Error!WipSwitch { try self.ensureUnusedExtraCapacity(1, Instruction.Switch, cases_len * 2); const instruction = try self.addInst(null, .{ .tag = .@"switch", .data = self.addExtraAssumeCapacity(Instruction.Switch{ .val = val, .default = default, .cases_len = cases_len, .weights = weights, }), }); _ = self.extra.addManyAsSliceAssumeCapacity(cases_len * 2); default.ptr(self).branches += 1; return .{ .index = 0, .instruction = instruction }; }